![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
#tail
To install:
npm install tail
#Use:
Tail = require('tail').Tail;
tail = new Tail("fileToTail");
tail.on("line", function(data) {
console.log(data);
});
tail.on("error", function(error) {
console.log('ERROR: ', error);
});
Tail constructor accepts few parameters:
var fileToTail = "/path/to/fileToTail.txt";
var lineSeparator= "\n";
var fromBeginning = false;
var watchOptions = {}; \\ as per node fs.watch documentations
new Tail(fileToTail, lineSeparator, watchOptions,fromBeginning)
fileToTail
is the name (inclusive of the path) of the file to taillineSeparator
is the line separator token (default "\n")watchOptions
is the full set of options that can be passed to fs.watch
as per node documentation (default: {})fromBeginning
force the tail of the file from the very beginning of it instead of from the first new line that will be appended(default: "\n")The only mandatory one is the first, i.e. the the file you want to tail.
Tail emits two type of events:
function(data){}
function(exception){}
If you simply want to stop the tail:
tail.unwatch()
And to start watching again:
tail.watch()
#Want to fork ?
Tail is written in CoffeeScript.
The Cakefile generates the javascript that is then published to npm.
#License MIT. Please see License file for more details.
FAQs
tail a file in node
The npm package tail receives a total of 149,251 weekly downloads. As such, tail popularity was classified as popular.
We found that tail demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.